package cn.wolfcode.wolf2w.job;

import cn.wolfcode.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.redisService.IStrategyStatisVOService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**定时任务执行器
 * redis数据持久化
 */
//@Component
public class RedisDataPersistenceJob {
    @Autowired
    private IStrategyStatisVOService strategyStatisVOService;

    @Autowired
    private IStrategyService strategyService;
    @Scheduled(cron = "0/5 * * * * ? ")
    public void doWork(){
        System.out.println("----------------C持久化------------------------");
        //获取所有的攻略vo数据
        List<StrategyStatisVO> vos =  strategyStatisVOService.findByVoAll("*");
        //收藏持久化
        strategyStatisVOService.findByUid("*");

        for (StrategyStatisVO vo : vos) {
            strategyService.updateStatisVo(vo);
        }
    }

}
